package cn.xtits.xtf.common.spring.db.aspect;

import cn.xtits.xtf.common.spring.db.DynamicDataSourceShardHolder;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2016/3/4.
 */
@Aspect
@Component
public class DbShardAspect {

    @Pointcut("@annotation(cn.xtits.xtf.common.spring.db.annotation.DbShardName)")
    public  void mapperAspect() {
    }

    @Before("mapperAspect()")
    public void before(JoinPoint joinPoint){
        joinPoint.getSignature().getDeclaringType();
    }

    @After("mapperAspect()")
    public void afterThrow(JoinPoint joinPoint){
        DynamicDataSourceShardHolder.clear();
    }

    @After("mapperAspect()")
    public void after(JoinPoint joinPoint){
        DynamicDataSourceShardHolder.clear();
    }


}
